<?php

namespace app\api\controller;

use app\api\service\ExaminationService;
use app\api\validate\ExaminationValidate;

class Examination extends Base
{
    protected $middleware = ['NotFoundMiddleware'];

    /**
     * 获取考试列表
     * @needLogin FALSE
     * @method GET
     * @return void
     */
    public function getExamList()
    {
        if (($msg = ExaminationValidate::getExamList($this->params)) !== true) apiReturn(201, $msg);
        list($code, $msg, $data) = ExaminationService::getExamList($this->params);
        apiReturn($code, $msg, $data);
    }

    /**
     * 获取考试详情
     * @needLogin FALSE
     * @method GET
     * @return void
     */
    public function getExamInfo()
    {
        if (($msg = ExaminationValidate::getExamInfo($this->params)) !== true) apiReturn(201, $msg);
        list($code, $msg, $data) = ExaminationService::getExamInfo($this->params);
        apiReturn($code, $msg, $data);
    }

    /**
     * 提交考试内容
     * @needLogin TRUE
     * @method POST
     * @return void
     */
    public function subExamInfo()
    {
        if (($msg = ExaminationValidate::subExamInfo($this->params)) !== true) apiReturn(201, $msg);
        list($code, $msg, $data) = ExaminationService::subExamInfo($this->params, $this->_user_info);
        apiReturn($code, $msg, $data);
    }
}